from flask import Blueprint
from flask_jwt_extended import get_current_user, get_jwt_identity, jwt_required
from utils import sm4
from .casbin import casbin as CasbinRouter
from common.constant import message as msg

router = Blueprint("hello world", __name__, url_prefix="/test")

router.register_blueprint(CasbinRouter)


@router.get("/1")
def hello_world():
    """hello world 接口， 返回hello world SM4加密内容"""
    return sm4.encode_sm4(msg.HELLO_WORLD)


# 测试接口
@router.post("/protect")
@jwt_required()
def auth_test():
    """JWT 测试接口，无返回项"""
    print(get_jwt_identity())
    print(get_current_user())
    return ""
